#include "Subject.h"

void Subject::attach(Observer* observer)
{
    m_observers.push_back(observer);
}

void Subject::detach(Observer* observer)
{
    m_observers.remove(observer);
}

void Subject::setValue(int val)
{
    m_nVal = val;
    notify();
}

void Subject::notify()
{
    for (list<Observer*>::iterator it = m_observers.begin(); it != m_observers.end(); it++)
    {
        (*it)->update(m_nVal);
    }
}
